<?php
/**
 * 日志表
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/12/25
 * Time: 15:28
 */
namespace App\Models;
use DB;
use Schema;

use Illuminate\Database\Eloquent\Model;
class Logs extends Model{
    protected $guarded = [];
    protected $table;
    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        $this->table = 'logs_'.date('Ym');
        if (!Schema::hasTable($this->table))
        {
            DB::update('create table lpw_'.$this->table.' like lpw_logs');
        }
    }

    /*
     *批量添加数据
     */
    public  function addAll(Array $data)
    {
        $rs = DB::table($this->getTable())->insert($data);
        return $rs;
    }
}